/*
 * @Author: sz
 * @Date: 2023-10-26 09:16:15
 * @LastEditors: sz
 * @LastEditTime: 2023-11-15 15:32:11
 * @Description: file content
 */
import {request, removeAuthorization} from '@/utils/request'

/**
 * 登录服务
 * @param name 账户名
 * @param password 账户密码
 * @returns {Promise<AxiosResponse<T>>}
 */
export async function login(data) {
  return request('admin/index/login', 'post', data)
}

export async function userInfo(){
  return request('admin/index/userInfo', 'get');
}

export async function savePassword(data){
  return request('admin/index/savePassword', 'post',{
    data:{
      brand_id: process.env.VUE_APP_BRAND_ID,
      ...data
    }
  })
}
/**
 * 退出登录
 */
export function logout() {
  localStorage.removeItem(process.env.VUE_APP_ROUTES_KEY)
  localStorage.removeItem(process.env.VUE_APP_PERMISSIONS_KEY)
  localStorage.removeItem(process.env.VUE_APP_ROLES_KEY)
  removeAuthorization()
}

export default {
  login,
  logout,
  userInfo
}
